package tspda

import glory.xxd.Utils
import tsCIM.ResultCode
import tsCIM.modelForInterface.Header
import tsCIM.modelForInterface.RequestModel
import tsCIM.modelForInterface.ResultModel
import tsCIM.modelForInterface.Return

class PDALotInRequestController {

    def commentService
    def index() {
        def result = ResultModel.getResultModel()
        try {
            def USERNAME = params.USERNAME?:""
            def EQPID = params.EQPID?:""
            def MACHINENAME = params.MACHINENAME?:""
            def LOTID = params.LOTID?:""
            def body = [USERNAME:USERNAME,EQPID:EQPID,LOTID:LOTID]
            Header header = new Header(TRANSACTIONID:Utils.getUUID(),MESSAGENAME:"PDALotInRequest",MACHINENAME:MACHINENAME)
            Return aReturn = new Return()
            RequestModel requestModel = new RequestModel(header: header,body: body,aReturn: aReturn)
//            result = commentService.getJsonByTopic2Queue(requestModel,"sendmqname","returnmqname",true,responseXml)
            result = commentService.getJsonByTopic2Queue(requestModel,"jms.topic.PDA.TO.CIM","jms.queue.CIM.PDA.Send",false,false)
        }catch (Exception e){
            result.put(ResultModel.ServerErrorFlag,true)
            result.put(ResultModel.Code,ResultCode.SERVER_INTERFACE_ERROR.code)
            result.put(ResultModel.Msg,ResultCode.SERVER_INTERFACE_ERROR.msg)
            result.put(ResultModel.Data,e.getMessage())
        }finally{
            render Utils.getFormatString(result)
        }
    }

    def responseXml = """
<MESSAGE>
<HEADER>
  <TRANSACTIONID>c4c95384-b686-49f7-92a6-87295ab51a8f</TRANSACTIONID>
  <MESSAGENAME>PDALotInResponse</MESSAGENAME>
  <MACHINENAME>WM-2112</MACHINENAME>
  <WORKNO>2</WORKNO>
  <EVENTUSER>CIM</EVENTUSER>
  <EVENTTIME>2019-05-15 09:33:21.464</EVENTTIME>
</HEADER>
<BODY>
  <MATERIALPROPLIST>
    <MATERIALPROP>
      <MATERIALTYPE>LF</MATERIALTYPE>
      <MATERIALMODEL />
      <MATERIALSIZE>170×240 A-5P</MATERIALSIZE>
      <MATERIAL_ID>01.02.02.15.13</MATERIAL_ID>
    </MATERIALPROP>
    <MATERIALPROP>
      <MATERIALTYPE>Epoxy</MATERIALTYPE>
      <MATERIALMODEL>84-1</MATERIALMODEL>
      <MATERIALSIZE>/</MATERIALSIZE>
      <THAWING_END_TIME />
      <THAWING_START_TIME />
      <EXPIRATION_TIME />
    </MATERIALPROP>
    <MATERIALPROP>
      <MATERIALTYPE>SuctionNozzle</MATERIALTYPE>
      <MATERIALSIZE>R3-33</MATERIALSIZE>
    </MATERIALPROP>
    <MATERIALPROP>
      <MATERIALTYPE>Thimble</MATERIALTYPE>
      <MATERIALSIZE>150MIC*2</MATERIALSIZE>
    </MATERIALPROP>
    <MATERIALPROP>
      <MATERIALTYPE>Nozzle</MATERIALTYPE>
      <MATERIALSIZE>0.42</MATERIALSIZE>
    </MATERIALPROP>
  </MATERIALPROPLIST>
  <EQPID>DB-484</EQPID>
  <LOTID>DIP00719051406504</LOTID>
  <CURRENTSTEP>4</CURRENTSTEP>
  <DIAGRAM>BDM-00015042_B-US006</DIAGRAM>
  <PACKAGINGFORM>DIP007(D)</PACKAGINGFORM>
  <CUSTOMERCODE>US006</CUSTOMERCODE>
  <PRODUCTMODEL>TOP253PN0004</PRODUCTMODEL>
  <DIEMODEL>DS13D-SEC</DIEMODEL>
  <WAFERNO>W3246-C211</WAFERNO>
  <DIESIZE>0</DIESIZE>
  <INITIALTHICKNESS>0</INITIALTHICKNESS>
  <WAFERCONTROLCARDTYPE>NULL</WAFERCONTROLCARDTYPE>
  <FINALTHICKNESS>0</FINALTHICKNESS>
  <COATINGTHICKNESS>0</COATINGTHICKNESS>
  <WAFERTHICKNESS>0</WAFERTHICKNESS>
  <ISLBG>0</ISLBG>
  <TABLETS>0</TABLETS>
  <DONETABLETS>0</DONETABLETS>
  <DONEQTY>0</DONEQTY>
  <WORKORDERQTY>0</WORKORDERQTY>
  <ISPROCESSSTART>false</ISPROCESSSTART>
  <OPID>10014284</OPID>
  <ISSTATUS>Y</ISSTATUS>
</BODY>
<RETURN>
  <RETURNCODE>0</RETURNCODE>
  <RETURNMESSAGE>OO</RETURNMESSAGE>
</RETURN>
</MESSAGE>
    """
}

